﻿//  Created by Mathew Purchase.
//  Copyright (c) 2014 Mathew Purchase. All rights reserved.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;


public class UI_Navigation : MonoBehaviour 
{

	//---------------------------------------------------------------------------------------------
	// Properties

	string playerLocation;
	
	//---------------------------------------------------------------------------------------------
	// Members
	public Text m_playerLocation;
	public Text m_Thirst;
	public Text m_Hunger;
	public Text m_Energy;
	public Text m_Health;
	public Text m_Gold;
	public Character m_player;
	
	terrainGeneration m_terrainMain;

	//---------------------------------------------------------------------------------------------
	// Events and Delegates
	
	
	//---------------------------------------------------------------------------------------------
	// Init
	
	void Start () 
	{
		m_terrainMain = GameObject.Find("TerrainService").GetComponent<terrainGeneration>();
		Character.playerMoved += PlayerLocation;
	}
	
	void OnDisable()
	{
		Character.playerMoved -= PlayerLocation;
	}
	
	//---------------------------------------------------------------------------------------------
	// Core Functions

	void Update () 
	{
		m_Thirst.text = m_player.thirst.ToString();
		m_Hunger.text = m_player.hunger.ToString();
		m_Energy.text = m_player.energy.ToString();
		m_Health.text = m_player.health.ToString();
		m_Gold.text = m_player.gold.ToString();
	}
	
	//---------------------------------------------------------------------------------------------
	void PlayerLocation ()
	{
		if (m_player.inSettlement == true)
		{
			playerLocation = m_terrainMain.m_terrainPieces[m_player.location_x,m_player.location_z].GetComponent<settlementPiece>().SettlementName;
		}
		else 
		{
			playerLocation = m_terrainMain.m_terrainPieces[m_player.location_x,m_player.location_z].name;
		}
		
		m_playerLocation.text = playerLocation;
		
		
		
	}
}
